package com.ynhenc.pta.routeRank;

import java.awt.geom.*;

import com.ynhenc.pta.routeRank.impl.ComLib_PTA;

public class Vertex extends Point2D.Double implements KmlInterface {

	public Vertex(double x, double y) {
		super(x, y);
	}

	public boolean isNode() {
		return false;
	}

	public Vertex getWgs84ToTm() { 
		if( this.tm == null ) {
			this.tm = Wgs84ToTm.getWgs84ToTm( this );  
		}
		return this.tm;
	}

	public void toKml(StringBuffer buff) {
		buff.append(this.getX() + "," + this.getY() + ",0");
	}

	protected String getCode() {
		return "V";
	}

	public String toString() {
		return this.getCode() + ", x:" + this.getX() + ", y:" + this.getY();
	}
	
	public double getDirectDistance_Meter( Vertex b ) {
		return Vertex.getWgsDistance_Meter( this, b );
	}
	
	private static double getWgsDistance_Meter( Vertex a, Vertex b ) {
		Vertex atm = a.getWgs84ToTm();
		Vertex btm = b.getWgs84ToTm();
		
		double dx = atm.getX() - btm.getX();
		double dy = btm.getY() - btm.getY();
		
		return Math.sqrt( dx*dx + dy*dy);
	}
	
	private Vertex tm ;

}
